package com.zhangdi.demo.es.config;

import com.zhangdi.demo.es.entity.CompanyDoc;
import com.zhangdi.mserver.searchcli.repository.ClientApi;
import com.zhangdi.mserver.searchcli.repository.ClientBase;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

/**
 * Created by zhangdi on 2020/06/30 09:50:42.
 */

@EnableElasticsearchRepositories("com.zhangdi.demo.es.esrepository")
//@EnableMongoRepositories("com.zhangdi.demo.es.mongorepository")
@Configuration
public class JPAConfig {
//    @Bean
//    MongoTransactionManager transactionManager(MongoDatabaseFactory factory) {
//        return new MongoTransactionManager(factory);
//    }

    @Bean
    public ClientApi<CompanyDoc> clientApi(){
        HttpHost node = new HttpHost("127.0.0.1", 9200);
        ClientApi c = new ClientBase(RestClient.builder(node));
        return c;
    }
}
